#pragma once
#include <unordered_map>
#include <string>
#include <sstream>
typedef  std::unordered_map<std::string,std::unordered_map<std::string, std::string>*> STR_MAP;
class ConfigFile {
    public:
        ~ConfigFile();
    // 设计成单例模式
    private:
        ConfigFile() {};
        static ConfigFile* _instance;
    public:
        std::stringstream& operator[] (const std::string& name);
       static ConfigFile& instance();
    private:
        bool isSection(const std::string line, std::string& section);
        unsigned parseNumber(const std::string& s);
        std::string trimLeft(const std::string& s);
        std::string trimRight(const std::string& s);
        std::string trim(const std::string& s);
        bool Load(const std::string& path);
    private:
        std::stringstream _istr;
        STR_MAP _map;
    public:
        void clear();
        static bool setPath(const std::string& path);
};
